package com.smap.common;

public class GeoAPI {

	Callback callback;

	public GeoAPI(Callback callback) {
		this.callback = callback;
	}

	public void foundLocation(String lonLat) {
		String[] lonlats = lonLat.split(",");
		callback.exe(Double.parseDouble(lonlats[0]),
				Double.parseDouble(lonlats[1]));
	}

	public native String getLoc() /*-{
		var that = this;
		if (navigator.geolocation) {
			navigator.geolocation
					.getCurrentPosition(function(position) {
						//console.debug(position);
						var lat = position.coords.latitude;
						var lon = position.coords.longitude;
						var str = lon + "," + lat;
						that.@com.smap.common.GeoAPI::foundLocation(Ljava/lang/String;)(str);
					});
		}
	}-*/;
}
